<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>天气案例</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<!--准备好一个容器-->
<div id="root">
    <h2>
        今天天气很{{info}}
    </h2>
<!--    <button @click="changeWeather($event)">切换城市</button>-->
    <button @click="isHot=!isHot">切换城市</button>
</div>
<script type="text/javascript">
    const vm = new Vue({
        el: '#root',
        data: {
            isHot: true,
            //window:window//简写为window
        },
        methods: {
            changeWeather() {
                this.isHot = !this.isHot;
            }
        },
        computed: {
            info: function () {
                return this.isHot === true ? '炎热' : '凉爽';
            }
        }
    });
    console.log(vm);
</script>
</body>
</html>